home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2942 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.2 KB

  1. Path: Rezonet.net!news
  2. From: ray@ultimate-tech.com (Ray Dunn)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: quick decision: is n a power of 2?
  5. Date: 25 Jan 1996 03:02:24 GMT
  6. Organization: Ultimate Technographics Inc.
  7. Message-ID: <4e6rs0$dvl@ns.RezoNet.NET>
  8. References: <Pine.OSF.3.91.960119114608.18779E-100000@io.UWinnipeg.ca> <TANMOY.96Jan21104404@qcd.lanl.gov>
  9. NNTP-Posting-Host: 204.19.230.7
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=US-ASCII
  12. X-Newsreader: WinVN 0.99.7
  13.  
  14. In referenced article, Tanmoy Bhattacharya says...
  15. >Consider x = 0...0101. -x = 1...1011
  16. >-x & x == 1. So I cannot quite figure out what was meant above.
  17. >
  18. >x && !(x & ~-x) is a possible solution: But since ~-x is the same as
  19. >(x-1), this is the same as an already posted answer. (I am sorry that
  20. >in my hurry I missed the x && bit in a previous post).
  21. >
  22. >Instead of calling for 2's complement arithmetic, I prefer to say that
  23. >these should only be used for unsigned types. 
  24.  
  25. I don't undersand this last comment.  None of the examples you show 
  26. work except in two's complement arithmetic.
  27.  
  28. -- 
  29. Ray Dunn (opinions are my own) | Phone: (514) 938 9050
  30. Montreal                       | Phax : (514) 938 5225
  31. ray@ultimate-tech.com          | Home : (514) 630 3749
  32.  
  33.